# 关键字
import keyword

print(keyword.kwlist)

# 变量
name = "张三"
# type 获取变量的类型
print(name, type(name))

age = 23
print(age, type(age))

# 动态数据类型
# 变量的类型自动推断出来
# 变量的类型可以改变
age = "23"
print(age, type(age))

# 业界预定大写代表常量
PI = 3.1415926

# 单行注释
'''
多行注释
多行注释
多行注释
多行注释
'''

"""
多行注释
多行注释
多行注释
多行注释
"""

# 多行字符串
sql = """
    select 
    clazz,
    count(1)as num 
    from 
    students 
    group by clazz
"""
print(sql, type(sql))

# 数量类型
i = 100
print(i, type(i))

PI = 3.1415926
print(PI, type(PI))

name = "张三"
print(name, type(name))

b = False
print(b, type(b))

# 转义字符
print("001\t张三\t23")
print(r"001\t张三\t23")

id = "001"
name = "张三"
age = 23

# 格式化字符串
print("id:%s,name:%s,age:%d" % (id, name, age))
print(f"id:{id},name:{name},age:{age}")

print("=" * 100)

# 算术运算符
i = 100
j = 6
print(i + j)
print(i - j)
print(i * j)
print(i / j)
print(i // j)
print(i % j)
print(i ** j)

# 赋值运算符
i = 100
i += 1
print(i)
i **= 2
print(i)

# 逻辑运算符
print(True and True)
print(True or True)
print(not True)

# if语句
# name = input("请输出姓名。。")
# if name == "张三":
#     print("姓名是张三")
# elif name == "李四":
#     print("姓名是李四")
# else:
#     print("其他")

# for
list = [1, 2, 3, 4, 5, 6, 7, 8]
print(list, type(list))

for i in list:
    print(i)

# while
i = 10
sum = 1
while i >= 1:
    if i % 2 == 0:
        i -= 1
        # 跳过当前循环进入下一次循环
        # break：退出循环
        continue
    sum *= i
    i -= 1
print(sum)

# 命名空间
name = "张三"
print(name)

age = 20
if age >= 18:
    desc = "成年"
else:
    desc = "未成年"

print(desc)
